package org.zuel.lkq.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zuel.lkq.param.user.talk.*;
import org.zuel.lkq.service.UserTalkService;

@RestController
@Api(tags = "工单系统: 用户工单管理模块")
@RequestMapping(value="/user_question")
public class UserTalkController {

    private UserTalkService userTalkService;

    @Autowired
    public UserTalkController(UserTalkService userTalkService) {
        this.userTalkService = userTalkService;
    }

    @ApiOperation(value = "发起工单")
    @RequiresPermissions("user_q:create")
    @PostMapping(value = "/create")
    public Object createQuestion(@RequestBody CreateQuestionParam param) {
        return userTalkService.createQuestion(param);
    }

    @ApiOperation(value = "查询所有工单")
    @RequiresPermissions("user_q:query")
    @PostMapping(value = "/query")
    public Object queryQuestion(@RequestBody QueryQuestionParam param) {
        return userTalkService.queryAllQuestion(param);
    }

    @ApiOperation(value = "工单详情")
    @RequiresPermissions("user_q:ques_detail")
    @PostMapping(value = "/ques_detail")
    public Object questionDetail(@RequestBody TalkDetailParam param) {
        return userTalkService.questionDetail(param);
    }


    @ApiOperation(value = "用户端交流详情")
    @RequiresPermissions("user_q:talk_detail")
    @PostMapping(value = "/talk_detail")
    public Object talkDetail(@RequestBody TalkDetailParam param) {
        return userTalkService.talkDetail(param);
    }

    @ApiOperation(value = "用户新增回复")
    @RequiresPermissions("user_q:talk_create")
    @PostMapping(value = "/talk_create")
    public Object talkCreate(@RequestBody TalkCreateParam param) {
        return userTalkService.createTalkDetail(param);
    }

    @ApiOperation(value = "用户终结工单")
    @RequiresPermissions("user_q:terminate")
    @PostMapping(value = "/terminate")
    public Object terminateQuestion(@RequestBody TerminateQuestionParam param) {
        return userTalkService.terminateQuestion(param);
    }
}
